﻿@model MessageRecodeListModel
@using System.Globalization;
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">用户ID</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" name="UserId" id="UserId" placeholder="请输入用户" autocomplete="off">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" name="Phone" id="Phone" placeholder="请输入手机号" autocomplete="off">
                    </div>
                </div>
                <br />
                <div class="layui-inline" style="margin-top:20px">
                    <label class="layui-form-label">开始日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="StartTime" id="StartTime" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-top:20px">
                    <label class="layui-form-label">结束日期</label>
                    <div class="layui-input-inline">
                        <input type="text" name="EndTime" id="EndTime" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-top:20px">
                    <button class="layui-btn" lay-submit lay-filter="LAY-app-contlist-search">搜索</button>
                </div>
            </div>
        </div>
        <div class="layui-card-body">
            <table id="LAY-topic-list" lay-filter="LAY-topic-list"></table>
            <script type="text/html" id="layuiadmin-app-cont-tagsbar">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
    </div>

<script>
    layui.use(['index', 'table'], function () {
            var index = layer.load(2, { shade: false });
        var table = layui.table;
        //分类管理
        table.render({
            elem: '#LAY-topic-list'
            , url: '@Html.Raw(Url.Action("InvitationCodeMessageList"))' //模拟接口
            ,method:'post'
            , page: true //开启分页
            , even: true
            , limit: 15
            , limits: [15,30,50,100]
            , cols: [[
                { type: 'numbers', fixed: 'left' }
                , { field: 'Id', width: 100, title: 'ID' }
                , { field: 'Code', title: '代码编号', minWidth: 100 }
                , { field: 'StartTime', title: '开始时间', minWidth: 150 }
                , { field: 'EndTime', title: '结束时间', minWidth: 150 }
                , { field: 'Phone', title: '电话', minWidth: 150 }
                , { title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#layuiadmin-app-cont-tagsbar' }
            ]]
            , id: 'testReload'
            , text: { none: '一条数据也没有^_^' }
            , done: function () {
                layer.close(index);
            }
        });
            //监听搜索
            layui.form.on('submit(LAY-app-contlist-search)', function (data) {
                var field = data.field;
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: field
                }, 'data');
            });
        //监听工具条
        table.on('tool(LAY-topic-list)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('确定删除？', function (index) {
                    obj.del();
                    $.post('@Url.Action("Delete")', { id: obj.data.Id });
                    layer.close(index);
                });

            } else if (obj.event === 'edit') {
                var tr = $(obj.tr);
                var index = layer.open({
                    title: '编辑'
                    , type: 2
                    , shade: 0.2
                    , maxmin: true
                    , shadeClose: true
                    , area: ['100%', '100%']
                    , content: '@Url.Action("Edit")?id=' + data.Id
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });

        var $ = layui.$, active = {
            add: function () {
                var index = layer.open({
                    title: '编辑'
                    , type: 2
                    , shade: 0.2
                    , maxmin: true
                    , shadeClose: true
                    , area: ['100%', '100%']
                    , content: '@Url.Action("Edit")'
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        }
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>

